package com.webtest.listener;

import javax.servlet.http.HttpSessionActivationListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;
import javax.servlet.http.HttpSessionEvent;
import java.io.Serializable;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/8/21 13:55
 */
public class Customer implements HttpSessionBindingListener, HttpSessionActivationListener, Serializable {

    private static final long serialVersionUID = -8156677315020728631L;

    private String time;

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    @Override
    public void valueBound(HttpSessionBindingEvent httpSessionBindingEvent) {
        System.out.println("绑定到session");
        Object value = httpSessionBindingEvent.getValue();
        System.out.println(value == this);
        System.out.println(httpSessionBindingEvent.getName());
    }

    @Override
    public void valueUnbound(HttpSessionBindingEvent httpSessionBindingEvent) {
        System.out.println("从session中解除绑定");
    }

    @Override
    public void sessionWillPassivate(HttpSessionEvent httpSessionEvent) {
        System.out.println("从内存写入到硬盘上");
    }

    @Override
    public void sessionDidActivate(HttpSessionEvent httpSessionEvent) {
        System.out.println("从磁盘中读取出来");
    }

    @Override
    public String toString() {
        return "Customer{" +
                "time='" + time + '\'' +
                '}';
    }
}
